
use algo_lib as lib;

use  lib::queue::{Queue,PriorityQueue};

use lib::tree::btree::{Node,BinaryTree,BinarySearchTree};

mod stack_case;


fn main() {
	// quest_test();

	// pq_test();

	// btree_test();

	// number_bit_add();
	stack_case::run_par_checker1();
	stack_case::run_base_converter();
}


fn quest_test() {
	let mut q = Queue::<i32>::new();
	q.push(1);
	let mut ok = false;
	let val:Option<i32> = match q.pop() {
		Some(v) => {ok = true; Some(v)},
		None => {
			println!("There's no value in queue");
			None
		},
	};

	if ok {
		println!("{}", val.unwrap());
	}
}

fn pq_test() {
	let mut pq = PriorityQueue::new();
	assert!(pq.is_empty());

	pq.insert(3);
	pq.insert(2);

	assert!(!pq.is_empty());

	assert_eq!(pq.len(), 2);

	pq.insert(1);
	pq.insert(4);
	assert_eq!(pq.min().unwrap(), 1);
	assert_eq!(pq.max().unwrap(), 4);

	assert_eq!(pq.delete_max().unwrap(), 4);
	assert_eq!(pq.delete_min().unwrap(), 1);
}

fn btree_test() {
	type BST<K,V> = Node<K,V>;

	let mut root = BST::<i32, i32>::new(3,4);
	root.insert(2,3);
	root.insert(4,6);
	root.insert(5,5);
	root.insert(6,6);
	root.insert(1,8);
	if let Some(ref left) = root.left {
		assert_eq!(left.value, 3);
	}

	if let Some(ref right) = root.right {
		assert_eq!(right.value, 6);
		if let  Some(ref right) = right.right {
			assert_eq!(right.value, 5);
		}
	}

	println!("PreOrder");
	root.pre_order();

	println!("In Order");
	root.in_order();

	println!("Post Order");
	root.post_order();
}

fn number_bit_add() {
	let s1 = "1000111010101";
	let s2 =   "11011101101";
	let r = lib::number::add_bit_str( s1.as_bytes(), s2.as_bytes());
	println!("result: {} ", r);

	let v = lib::number::count_bit(10);
	println!("{:?}", v);

	let v1 = lib::number::count_bit_2(10);
	println!("{:?}", v1);
}

